#!/usr/bin/env bash
# 实例文件：command_substitution

REMOTE_HOST='host.example.com'
REMOTE_FILE='/etc/passwd'
SSH_USER='user@'
#SSH_ID='-i ~/.ssh/foo.id'
SSH_ID=''

result=$(
    ssh $SSH_ID $SSH_USER$REMOTE_HOST \
        "[ -r $REMOTE_FILE ] && echo 1 || echo 0 "
    ) || { echo "SSH command failed!" >&2; exit1; }
if [ $result = 1 ];then
    echo "$REMOTE_FILE present on $REMOTE_HOST"
else
    echo "$REMOTE_FILE not present on $REMOTE_HOST"
fi
